package vip.meeet.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import vip.meeet.bean.Result;
import vip.meeet.bean.echarts.ChartType;
import vip.meeet.bean.echarts.EData;
import vip.meeet.bean.echarts.Indicator;
import vip.meeet.helper.EchartsHelper;
import vip.meeet.helper.ResultHelper;

import java.util.Arrays;
import java.util.LinkedList;

@Controller
@RequestMapping("/radar")
public class RadarController {


    @RequestMapping("/one")
    @ResponseBody
    public Result one1(){
        LinkedList<Indicator> indicators = new LinkedList<>();
        LinkedList<Integer> A = new LinkedList<>();
        for(int i=1;i<7;i++){
            Indicator<Object> indicator = new Indicator<>();
            indicator.setName("type" + i);
            indicators.add(indicator);
            A.add(i + 3);
        }
        EData adata = EchartsHelper.buildSerie(ChartType.RADAR, "A", A);

        JSONObject result = EchartsHelper.buildRadarResult(
                "Radar",
                null,
                indicators,
                adata
        );
        return ResultHelper.getSuccessResult(result);
    }

    @RequestMapping("/two")
    @ResponseBody
    public Result two(){
        LinkedList<Indicator> indicators = new LinkedList<>();
        LinkedList<Integer> A = new LinkedList<>();
        LinkedList<Integer> B = new LinkedList<>();
        for(int i=1;i<7;i++){
            Indicator<Object> indicator = new Indicator<>();
            indicator.setName("type" + i);
            indicators.add(indicator);
            A.add(i + 3);
            B.add(i + 5);
        }
        EData adata = EchartsHelper.buildSerie(ChartType.RADAR, "A", A);
        EData bdata = EchartsHelper.buildSerie(ChartType.RADAR, "B", B);

        JSONObject result = EchartsHelper.buildRadarResult(
                "Radar",
                null,
                indicators,
                Arrays.asList(adata,bdata)
        );
        return ResultHelper.getSuccessResult(result);
    }

}
